package logic

import (
	"context"
	"elem_svc/models/mysql"

	"elem_svc/elem"
	"elem_svc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopNameAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopNameAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopNameAddLogic {
	return &ShopNameAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品添加
func (l *ShopNameAddLogic) ShopNameAdd(in *elem.ShopNameAddRequest) (*elem.ShopNameAddResponse, error) {
	// todo: add your logic here and delete this line

	name := mysql.ShopName{
		ShopId: int(in.ShopId),
		Name:   in.Name,
		Price:  float64(in.Price),
		Stock:  int(in.Stock),
	}

	mysql.DB.Debug().Create(&name)

	return &elem.ShopNameAddResponse{
		Id: int64(name.ID),
	}, nil
}
